package com.as.web;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.as.base.BaseController;
import com.as.entity.Test;
import com.as.entity.User;

@Controller
@RequestMapping("/parent")
public class ParentController extends BaseController{
	
	@ResponseBody 
	@RequestMapping("/getChild")
	public Map<String, Object> getChild(HttpSession httpSession){
		Map<String,Object> map = new HashMap<String, Object>();
		User user = (User)httpSession.getAttribute("user");
		User child = userManager.getUser(user.getRelateid());
		List<Test> list = testManager.getOnePersonTest(child.getUserid());
		map.put("child", child);
		map.put("tlist", list);
		return map;
	}
	
	@ResponseBody 
	@RequestMapping("/getParent")
	public Map<String, Object> getParent(HttpSession httpSession){
		Map<String,Object> map = new HashMap<String, Object>();
		User user = (User)httpSession.getAttribute("user");
		User parent = userManager.getUser(user.getRelateid());
		map.put("parent", parent);
		map.put("status", "OK");
		return map;
	} 
}
